<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>机构详情</title>
    <!-- 新 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css">

    <!-- 可选的Bootstrap主题文件（一般不用引入） -->
    <link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">

    <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
    <script src="http://cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>

    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="http://cdn.bootcss.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>

    <link rel="stylesheet" href="/css/font-awesome.css">
    <link rel="stylesheet" href="/css/base.css">
    <link rel="stylesheet" href="/css/djs.css">

    <script src="/json/CityJson.js" type="text/javascript" charset="utf-8"></script>
    <script src="/json/ProJson.js" type="text/javascript" charset="utf-8"></script>
    <script src="/json/DistrictJson.js" type="text/javascript" charset="utf-8"></script>
    <script src="/js/user.js"></script>
    <script type="text/javascript" src="/js/base.js"></script>
</head>
<body>
<div id="top">

</div>
<div class="container">
    <div id="asideAffix" class="aside" data-spy="affix">
    </div>
    <div class="content centers editcontent" style="margin-top: 0;">
        <form role="form" id="editForm" class="form-horizontal">
            <div class="form-group">
                <div class="col-sm-12">
                    <label for="onePass" class="col-sm-2">组织一号通：</label>
                    <label id="onePass" class="col-sm-6"></label>
                </div>

                <div class="col-sm-12">
                    <label for="orgName" class="col-sm-2">组织名称：</label>
                    <label id="orgName" class="col-sm-6"></label>
                </div>

                <div class="col-sm-12">
                    <label for="county" class="col-sm-2">地址信息：</label>
                    <div class="col-sm-6">
                        <label id="province"></label>
                        <label id="city"></label>
                        <label id="county"></label>
                    </div>
                </div>
                <div class="col-sm-12">
                    <label for="address" class="col-sm-2">详细地址：</label>
                    <label id="address" class="col-sm-6"></label>
                </div>
                <div class="col-sm-12">
                    <label for="zipCode" class="col-sm-2">邮政编码：</label>
                    <label id="zipCode" class="col-sm-6"></label>
                </div>
                <div class="col-sm-12">
                    <label for="principal" class="col-sm-2">负责人姓名：</label>
                    <label id="principal" class="col-sm-6"></label>
                </div>
                <div class="col-sm-12">
                    <label for="phone" class="col-sm-2">负责人电话：</label>
                    <label id="phone" class="col-sm-6"></label>
                </div>
            </div>
            <div>
                <button type="button" class="col-sm-2 btn btn-primary" id="rollback"
                        style="border-color: #ffd632;background: #ffd632 linear-gradient(to bottom,#ffd632 0,#ffd632 100%);">
                    返回
                </button>
            </div>
        </form>

    </div>
</div>
</body>

<script type="text/javascript">
    $(function () {

        if (location.search.substr(1).split("=")[1] != undefined && location.search.substr(1).split("=")[1] != 0) {
            getData(location.search.substr(1).split("=")[1]);
        }
    });

    function getAddress(type,id){
        var tempName="";
        if(type == 1){
            $.each(province, function (k, p) {
                if (p.ProID == id) {
                    tempName = p.ProName;
                }
            });
        }else if(type == 2){
            $.each(city, function (k, p) {
                if (p.CityID == id) {
                    tempName = p.CityName;
                }
            });
        }else if(type == 3){
            $.each(District, function (k, p) {
                if (p.Id == id) {
                    tempName = p.DisName;
                }
            });
        }

        return tempName;
    }


    function getData(orgId) {
        $.ajax({
            url: '/org/info',// 跳转到 action
            headers: {'Content-type': 'application/json;charset=UTF-8'},//传入数据数据格式 json
            data: JSON.stringify({
                "orgId": orgId
            }),
            type: 'post',
            cache: false,
            dataType: 'json',
            success: function (data) {
                if (data.statusCode == 0) {
                    if (undefined != data.data) {
                        $("#onePass").text(data.data.onePass);
                        $("#orgName").text(data.data.orgName);
                        $("#orgId").text(data.data.orgId);
                        $("#province").text(getAddress(1,data.data.province));
                        $("#city").text(getAddress(2,data.data.city));
                        $("#county").text(getAddress(3,data.data.county));
                        $("#address").text(data.data.address);
                        $("#zipCode").text(data.data.zipCode);
                        $("#principal").text(data.data.principal);
                        $("#phone").text(data.data.phone);
                    }
                } else {
                    alert(data.statusMessage);
                }
            },
            error: function () {
                // view("异常！");
                alert("用户未登录或者服务器连接异常！");
            }
        });
    }

    $("#rollback").click(function () {
        back()
    });

    function back() {
        location.href = "/html/org/orgList.html";
    }
</script>
</html>